﻿/*
Commerce by Onex – eCommerce software platform (www.ecommerce.byonex.com)
Copyright (C) 2008-2010 by Onex Group

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace ShopModel
{
    /// <summary>
    /// Klasa umożliwiająca zmianę ceny przedmiotu (Klasa umożliwiająca zmianę ceny przedmiotu)
    /// </summary>
    [Serializable]
    public class PriceChange
    {
        #region VARIBLES

        Products _Product;
        List<ChangeItem> _Changes;

        #endregion

        #region CONSTRUCTORS

        public PriceChange() { _Changes = new List<ChangeItem>(); }

        #endregion

        #region FIELDS

        public List<ChangeItem> Changes
        {
            get { return _Changes; }
            set { _Changes = value; }
        }
        
        public Products Product
        {
            get { return _Product; }
            set { _Product = value; }
        }

        #endregion
    }

    /// <summary>
    /// Klasa umożliwiająca zmiane przedmiotu (Class that enables change of product)
    /// </summary>
    [Serializable]
    public class ChangeItem
    {
        #region VARIBLES

        int _ID;
        DateTime _ChangeDate;
        decimal _Price;
        decimal _VatRateValue;

        #endregion

        #region CONSTRUCTORS

        public ChangeItem() { }

        #endregion

        #region FIELDS

        public int ID
        {
            get { return _ID; }
            set { _ID = value; }
        }

        public DateTime ChangeDate
        {
            get { return _ChangeDate; }
            set { _ChangeDate = value; }
        }

        public decimal PriceNetto
        {
            get { return decimal.Round(_Price / (1 + _VatRateValue), 2); }
            set { _Price = decimal.Round(value * (1 + _VatRateValue), 2); }
        }

        public decimal PriceBrutto
        {
            get { return _Price; }
            set { _Price = value; }
        }

        public decimal VatRateValue
        {
            get { return _VatRateValue; }
            set { _VatRateValue = value; }
        }

        #endregion
    }
}
